home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 May / Disc 2 / PCU0503CD2.iso / Crystal / Samples / CPP / 32bit / Mycall / MAINVIEW.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-18  |  6.2 KB  |  223 lines

  1. // MainView.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MYCALL.h"
  6. #include "MainView.h"
  7. #include "MainFrm.h"
  8. #include "MYCALLDC.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // MainView
  17.  
  18. IMPLEMENT_DYNCREATE(MainView, CFormView)
  19.  
  20. MainView::MainView()
  21.     : CFormView(MainView::IDD)
  22. {
  23.     //{{AFX_DATA_INIT(MainView)
  24.         // NOTE: the ClassWizard will add member initialization here
  25.     //}}AFX_DATA_INIT
  26. }
  27.  
  28. MainView::~MainView()
  29. {
  30. }
  31.  
  32. void MainView::DoDataExchange(CDataExchange* pDX)
  33. {
  34.     CFormView::DoDataExchange(pDX);
  35.     //{{AFX_DATA_MAP(MainView)
  36.     DDX_Control(pDX, IDC_LIST1, m_mainList);
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(MainView, CFormView)
  42.     //{{AFX_MSG_MAP(MainView)
  43.     ON_WM_SIZE()
  44.     ON_COMMAND(ID_CLEARWINDOW, OnClearwindow)
  45.     ON_UPDATE_COMMAND_UI(ID_CLEARWINDOW, OnUpdateClearwindow)
  46.     ON_BN_CLICKED(IDC_SETCURSOR, OnSetcursor)
  47.     ON_UPDATE_COMMAND_UI(IDC_SETCURSOR, OnUpdateSet)
  48.     //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // MainView diagnostics
  53.  
  54. #ifdef _DEBUG
  55. void MainView::AssertValid() const
  56. {
  57.     CFormView::AssertValid();
  58. }
  59.  
  60. void MainView::Dump(CDumpContext& dc) const
  61. {
  62.     CFormView::Dump(dc);
  63. }
  64. #endif //_DEBUG
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // MainView message handlers
  68.  
  69. void MainView::OnDraw(CDC* pDC) 
  70. {
  71.     // TODO: Add your specialized code here and/or call the base class
  72.         CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  73.     
  74. }
  75.  
  76. void MainView::OnInitialUpdate() 
  77. {
  78.     CFormView::OnInitialUpdate();
  79.     CMainFrame*  mainFrame = (CMainFrame *) AfxGetMainWnd();
  80.     CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  81.     pDoc->m_listBox = &m_mainList;
  82.     RECT temp;
  83.     GetClientRect(&temp);
  84.  
  85.     CRect rect(7,25,202,200);
  86.  
  87.     m_Area.Create(WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|CBS_NOINTEGRALHEIGHT|CBS_DISABLENOSCROLL, rect, &(mainFrame->m_dialogBar), IDC_AREA);
  88.  
  89.     rect.SetRect(210,25,460,400);
  90.     m_CursorType.Create(WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST, rect, &(mainFrame->m_dialogBar), IDC_CURSORTYPE);
  91.  
  92.     InitializeCombo();
  93.     
  94.  
  95.  
  96.     m_Area.ClearVars();
  97.     m_CursorType.ClearVars();
  98.  
  99.     m_mainList.MoveWindow(0,0,temp.right, temp.bottom);
  100.     m_mainList.EnableWindow(FALSE);    
  101.     // TODO: Add your specialized code here and/or call the base class
  102.     
  103. }
  104.  
  105.  
  106. void MainView::OnSize(UINT nType, int cx, int cy) 
  107. {
  108.     CFormView::OnSize(nType, cx, cy);
  109.     if(IsWindow(m_mainList.m_hWnd)){
  110.     CRect r;
  111.         
  112.     GetClientRect (r);
  113.         
  114.     m_mainList.MoveWindow(0, 0, r.Width(), r.Height ());
  115.     }
  116.     // TODO: Add your message handler code here
  117.     
  118. }
  119.  
  120. void MainView::OnClearwindow() 
  121. {
  122.     // TODO: Add your command handler code here
  123.         CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  124.         pDoc->m_elementCount = 0;
  125.         m_mainList.ResetContent();
  126.  
  127. }
  128.  
  129. void MainView::OnUpdateClearwindow(CCmdUI* pCmdUI) 
  130. {
  131.     // TODO: Add your command update UI handler code here
  132.         CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  133.     (pDoc->m_crpeJob != NULL)? pCmdUI->Enable(): pCmdUI->Enable(FALSE);
  134. }
  135.  
  136. //  Initialize both comboboxes with area and cursor values.
  137. void MainView::InitializeCombo(void)
  138. {
  139.     m_Area.AddString("Group Area");
  140.     m_Area.AddString("Group Area Field");
  141.     m_Area.AddString("Detail Area");
  142.     m_Area.AddString("Detail Area Field");
  143.     m_Area.AddString("Graph Area");
  144.     
  145.     m_CursorType.AddString("PE_TC_DEFAULT_CURSOR");
  146.     m_CursorType.AddString("PE_TC_ARROW_CURSOR");
  147.     m_CursorType.AddString("PE_TC_CROSS_CURSOR");
  148.     m_CursorType.AddString("PE_TC_IBEAM_CURSOR");
  149.     m_CursorType.AddString("PE_TC_UPARROW_CURSOR");
  150.     m_CursorType.AddString("PE_TC_SIZEALL_CURSOR");
  151.     m_CursorType.AddString("PE_TC_SIZENWSE_CURSOR");
  152.     m_CursorType.AddString("PE_TC_SIZENESW_CURSOR");
  153.     m_CursorType.AddString("PE_TC_SIZEWE_CURSOR");
  154.     m_CursorType.AddString("PE_TC_SIZENS_CURSOR");
  155.     m_CursorType.AddString("PE_TC_NO_CURSOR");
  156.     m_CursorType.AddString("PE_TC_WAIT_CURSOR");
  157.     m_CursorType.AddString("PE_TC_APPSTARTING_CURSOR");
  158.     m_CursorType.AddString("PE_TC_HELP_CURSOR");
  159.     m_CursorType.AddString("PE_TC_MAGNIFY_CURSOR");
  160.     
  161.  
  162. }
  163. /* This function will set the selected area in the area combobox with the
  164. selected cursor in the cursor combobox.  It will update the status bar with the 
  165. value that has been selected.  
  166.  
  167. */
  168. void MainView::OnSetcursor() 
  169. {
  170.     // TODO: Add your control notification handler code here
  171.     PETrackCursorInfo trackCursor;
  172.     trackCursor.StructSize = PE_SIZEOF_TRACK_CURSOR_INFO;
  173.     trackCursor.groupAreaCursor = trackCursor.groupAreaFieldCursor = trackCursor.detailAreaCursor = trackCursor.detailAreaFieldCursor = 
  174.         trackCursor.graphCursor = PE_UNCHANGED;
  175.     CString output,temp;
  176.     switch(m_Area.GetCurrentSel()){
  177.     case 0:
  178.         trackCursor.groupAreaCursor = m_CursorType.GetPETC();
  179.         output = "Set Group Area Cursor to value: ";
  180.         break;
  181.     case 1:
  182.         trackCursor.groupAreaFieldCursor = m_CursorType.GetPETC();
  183.         output = "Set Group Area Field Cursor to value: ";
  184.         break;
  185.     case 2:
  186.         trackCursor.detailAreaCursor = m_CursorType.GetPETC();
  187.         output = "Set Detail Area Cursor to value: ";
  188.         break;
  189.     case 3:
  190.         trackCursor.detailAreaFieldCursor = m_CursorType.GetPETC();
  191.         output = "Set Detail Area Field Cursor to value: ";
  192.         break;
  193.     case 4:
  194.         trackCursor.graphCursor = m_CursorType.GetPETC();
  195.         output = "Set Graph Cursor to value: ";
  196.         break;
  197.     default:
  198.         break;
  199.     }
  200.     TRACE(" ga %d gaf %d da %d daf %d g %d\n", trackCursor.groupAreaCursor, trackCursor.groupAreaFieldCursor,
  201.         trackCursor.detailAreaCursor, trackCursor.detailAreaFieldCursor, trackCursor.graphCursor);
  202.     CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  203.     if(PESetTrackCursorInfo(pDoc->m_crpeJob->GetJobHandle(), &trackCursor)){
  204.         temp.Format("%d",m_CursorType.GetPETC());
  205.         output += temp;
  206.         pDoc->m_statusString = output;
  207.     }
  208.     else{
  209.         CString temp;
  210.         pDoc->m_statusString = "PE Error: ";
  211.         temp.Format("%d", pDoc->m_crpeJob->GetErrorCode());
  212.         pDoc->m_statusString += temp;
  213.     }
  214.  
  215. }
  216.  
  217. void MainView::OnUpdateSet(CCmdUI* pCmdUI)
  218. {
  219.     
  220.     CMYCALLDoc* pDoc = (CMYCALLDoc *)GetDocument();
  221.     (pDoc->m_crpeJob != NULL)? pCmdUI->Enable(): pCmdUI->Enable(FALSE);
  222. }
  223.